<html>
<head>
<meta charset="utf-8" />
<title>Chat</title>
<link rel="stylesheet" href="./res/themes/default/default.css" />
<script charset="utf-8" src="./res/kindeditor-min.js"></script>
<script charset="utf-8" src="./res/jquery-1.10.2.min.js"></script>
<script charset="utf-8" src="./res/lang/zh_CN.js"></script>
<script type="text/javascript">
        $(document).ready(function() {
		var date = new Date() ;
			
         //消息记录
         var chat_history= KindEditor.create( 'textarea[name="chat_history"]', {
					resizeType : 0,
					minWidth : '500px',
					width : '500px' ,
					readonlyMode : false,
					filterMode :false,
					allowPreviewEmoticons : false ,
	            items : [] 
				}) ;      
        
			
	      var input= KindEditor.create( 'textarea[name="input"]', {
					resizeType : 0,
                    newlineTag : "br",
					width : '500px' ,
					minWidth : '500px',
					fontSizeTable : [
					'10px', '12px', '16px', '20px', '24px'
					],
					allowPreviewEmoticons : false,
					items : [
							 'emoticons', 'fontsize', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
						'removeformat', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
						'insertunorderedlist' ]
				}) ;
				
        	//初始化
			  $("#tip").hide();			
					
				// 发送消息	
				$("#send").click(function() {
					$("#tip").hide();
				   	var content = input.html().trim();
				   	if(content == "") {
				    	$("#tip").show();
				    	return ;
					}
					var hour = date.getHours() + "";
					var minute = date.getMinutes() + "";
					var second = date.getSeconds() + "";
				   	var time = "<font color='#0000ff'> 李跃东  ";
				   	if (hour.length == 1)
				   	   var hour = "0" + hour ;
				   	if (minute.length == 1)
				   	   minute = "0" + minute ;
				   	if (second.length == 1)
				   	   second = "0" + second ;
				   	time = time + hour + ":" +minute + ":" +second ;
				   	chat_history.appendHtml(time);
				   	chat_history.appendHtml("<br>")
				   	chat_history.appendHtml(content);
				   	chat_history.appendHtml("<br>");
				   	chat_history.appendHtml("<br>");
				   	var scrollTop = chat_history.edit.doc.body.offsetHeight + 10 ;
				    chat_history.edit.doc.body.scrollTop = scrollTop ;
				   	input.text("") ; 
				   	input.focus();
				   	sendMsg(content);
				   });
				   
				   $("$close").click(function() {
				     closeWindow();
				   });
			 });
		</script>
</head>
<body>
	<textarea name="chat_history" id="chat_history"
		style="width: 500px; height: 300px;"></textarea>

	<div id="tip"
		style="background-color: #FFDEAD; color: red; width: 502px;">
		输入为空</div>

	<textarea name="input" id="input" style="width: 500px; height: 150px;"></textarea>

	<div id="tip" style="float: right">
		<input type="button" id="close" value="关闭">
		<input type="button" id="send" value="发送">
	</div>
</body>
</html>

